Skip to content

feat(spec,core): a scoped import lookup miss whose value exists under another parent answers reference_out_of_scope - #37567

Draft
objectstack-fleet[bot] wants to merge 4 commits into
mainfrom
claude/project-thread-zt8cu4
Draft

objectstack-fleet[bot] wants to merge 4 commits into
mainfrom
claude/project-thread-zt8cu4

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Sales · project thread

Part of #36794 (PR-1 of 2: the spec reason and the importer; the Import Wizard text follows in PR-2 on the same branch once this one lands)

Clause-②: yes (widening)
Metadata-protocol: added (ValidateDataIssueSchema.scope, a new optional key on the import cell error; the new FieldErrorCode value is a wire code, no author-writable key)
Skills-docs: follow-up #37590

维护者速读

  • 导入时,查找列填了一个只在别的父记录下存在的记录(例如合同属于另一个客户),服务端现在单独报“不在本行的范围内”,并把限定它的列和单元格作为数据返回;真正不存在的值照旧报“找不到记录”。
  • 这是导入查找报错专题的后半段:上一张已让报错文字带上限定列,这张让依赖错误码的界面(导入向导)也能分清两种情况。
  • 只影响导入失败行的错误码和多出的一个可选字段,成功导入不受影响;按旧错误码筛“找不到”的客户端,在这种情况下会收到新码,可整张撤回。
  • 无。

What changes

  • FieldErrorCode gains reference_out_of_scope (packages/spec/src/api/errors.zod.ts, ADR-0114 D2 closed catalog), beside reference_not_found. Ruled route A on the card.
  • Catalog sentence import_reference_out_of_scope in all four platform locales (packages/spec/src/system/validation-message.ts). The English text is byte-identical to the sentence the scoped refusal already shipped with (Contract: no record matches "CTR-0006" (Account = "Acme")), now with {{scope}} as a parameter, so a deployment can override it under validation.field.import_reference_out_of_scope and the other three locales say it in their own word order.
  • ValidateDataIssueSchema gains an optional scope: [{ field, value }] (packages/spec/src/api/protocol.zod.ts), present only on an import cell error whose code is reference_out_of_scope. This is the thread's route decision, agreed by the seat at claim time: the card asks the Wizard to name the scoping column and its cell while keying on the code and never parsing server prose, and the row result carried no structured column at all. Same { field, value } naming the importer already uses for the columns; additive, optional, Clause-② widening. The contract review below judges it.
  • Core importer (packages/core/src/utils/import-coerce.ts, import-runner.ts): the fix(core): a scoped import lookup miss names the scoping column when the value exists outside the scope #36735 unscoped probe now answers the new reason with the new message key and the scope entries; the runner copies scope onto the row's errors element. A value nobody has keeps reference_not_found.
  • A scoped read the field-predicate guard refused is never probed (RefMatch.scopeDenied, isScopeFieldDenial). A caller who cannot read the scope field (a hidden master_detail field, or the param a dependsOn entry names) has the scoped lookup refused, so its miss says nothing about where the value lives. Before this PR the probe still ran and the fix(core): a scoped import lookup miss names the scoping column when the value exists outside the scope #36735 sentence named the scope; with a code that now claims "under another parent", that answer would be wrong for a record sitting under the row's own parent. It keeps reference_not_found and the plain sentence, which is what content/docs/data-modeling/import-mappings.mdx already says for that caller. The guard is read off the error's declared details.reason === 'field_predicate_denied' (the reason all four field-predicate guards answer) naming a scope field, never its message.
  • packages/runtime/src/dispatcher-error-vocabulary.ts: the new code's foreign-vocabulary row (ADR-0112 D6), same wording as its three siblings.
  • Docs: content/docs/api/error-catalog.mdx field-code table and content/docs/data-modeling/import-mappings.mdx scoped-lookup section. Regenerated: content/docs/references/api/{errors,export,protocol}.mdx, packages/spec/authorable-surface/api.json (api/ValidateDataIssue:scope), the strictness-ledger count for api/ (537 → 538, the new nested object).
  • Changeset: @objectstack/spec minor, @objectstack/core and @objectstack/runtime patch. Metadata-protocol: added, not the claim's none: Check Changeset reads the new api/ValidateDataIssue:scope row in packages/spec/authorable-surface/api.json as a key entered, and a kind other than none grades the package that carries it at least minor.

Tests

Local readings (tree f4a201e + 2e8b0b9)

Acceptance notes

  • Narrowing question left to the contract review, as the card asks: a client matching reason === 'reference_not_found' to mean "the lookup cell did not resolve" stops seeing the out-of-scope case under that value. The schema only widens (a new enum member, a new optional key), so this PR declares Clause-②: yes (widening); whether the move of that case is itself a narrowing for such a client is the L2's call.
  • Skill text made false, not fixed here (Skills-docs: follow-up owed): skills/objectstack-data/rules/relationships.md:117 says another master's detail answers reference_not_found. skills/** is governed, and this PR's Clause-②: yes keeps it off the low-risk arm, so the line here would make the whole PR Tier H; its follow-up card is skills: objectstack-data relationships rule says another master's detail is reference_not_found on import; after PR #37567 it is reference_out_of_scope #37590.
  • Between this PR and PR-2 the Import Wizard meets a code it has no case for, so formatDryRunError falls through to the server's own sentence (already in the caller's locale, naming the scope) on both the dry-run panel and the completion screen. PR-2 gives the code its own Wizard key built from scope.

Verification

Read first: packages/core/src/utils/import-coerce.ts referenceNotFound (the new reason and the guard), packages/core/src/utils/import-runner.ts the resolver's catch (isScopeFieldDenial), packages/spec/src/api/protocol.zod.ts ValidateDataIssueSchema.scope.

Two-minute check: pnpm --filter @objectstack/rest exec vitest run src/import-integration.test.ts -t "under another parent" — one test, green; row 2 answers reference_out_of_scope with its scope.


Generated by Claude Code

… another parent answers reference_out_of_scope

FieldErrorCode gains reference_out_of_scope, with its catalog sentence
import_reference_out_of_scope in all four platform locales. The importer
answers it for a scoped lookup cell whose value matches a record only
outside the row's scope, and the cell error carries the scoping columns as
`scope: [{ field, value }]` (ValidateDataIssueSchema), so a client keyed on
the code can name the column and its cell without parsing the message.
A value no record has keeps reference_not_found. A scoped read the
field-predicate guard refused is never probed, so it stays
reference_not_found too.

Claude-Session: https://claude.ai/code/session_01L6bhgWgMUXf5juNBhN6rLX
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation protocol:system tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/core, @objectstack/runtime, @objectstack/spec, touching 22 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/spec/authorable-surface/api.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/client-sdk.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/api/error-catalog.mdx (via FieldErrorCode (symbol, a top-level const object), reference_out_of_scope (literal, a string literal in FieldErrorCode; a string literal in UNREGISTERED_CODE_SITES; a string literal in referenceNotFound))
  • content/docs/api/error-handling-client.mdx (via FieldErrorCode (symbol, a top-level const object))
  • content/docs/api/error-handling-server.mdx (via FieldErrorCode (symbol, a top-level const object))
  • content/docs/api/wire-format.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/data-modeling/currency.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it), /:object/import/jobs (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/data-modeling/fields.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/data-modeling/import-mappings.mdx (via reference_out_of_scope (literal, a string literal in FieldErrorCode; a string literal in UNREGISTERED_CODE_SITES; a string literal in referenceNotFound), /:object/import (route, bridged from symbol runImport — its route source's handler names it), /:object/import/jobs (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/permissions/authorization.mdx (via field_predicate_denied (literal, a string literal in a comment on a changed line; a string literal in isScopeFieldDenial))
  • content/docs/permissions/system-context.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it), /:object/import/jobs (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/protocol/kernel/error-handling.mdx (via FieldErrorCode (symbol, a top-level const object))
  • content/docs/protocol/objectql/state-machine.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it), /:object/import/jobs (route, bridged from symbol runImport — its route source's handler names it))

⛔ 5 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v12.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/releases/v17/17-0.mdx (via FieldErrorCode (symbol, a top-level const object))
  • content/docs/releases/v17/17-6.mdx (via runImport (symbol, a top-level function), /:object/import (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/releases/v18/18-1.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/releases/v18/18-2.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/spec/authorable-surface/api.json) — pages documenting those are invisible to this run
  • 4 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 187 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 6c290d3af7c52d019d1de1c09b6b0306f09700bb → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 1aab83e008917f501af2fcee095f67a62ce4f6b3 — the merge of head 80a79c7732c04fc57b067c26aa74bdabe5b34604 into base 6c290d3af7c52d019d1de1c09b6b0306f09700bb, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 1aab83e008917f501af2fcee095f67a62ce4f6b3 && git checkout 1aab83e008917f501af2fcee095f67a62ce4f6b3
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 6c290d3af7c52d019d1de1c09b6b0306f09700bb 80a79c7732c04fc57b067c26aa74bdabe5b34604 && git checkout -B drift-repro 6c290d3af7c52d019d1de1c09b6b0306f09700bb && git merge --no-ff 80a79c7732c04fc57b067c26aa74bdabe5b34604

node scripts/docs-audit/affected-docs.mjs --json 6c290d3af7c52d019d1de1c09b6b0306f09700bb

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 6c290d3af7c52d019d1de1c09b6b0306f09700bb → pass the list as
args.docs, on the commit named under Which tree this was computed on.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:system size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants